package com.bwie.xujiahaonewstitle.httputils;

import android.content.Context;

import com.android.volley.Response;
import com.android.volley.VolleyError;

/**
 * 项目名称
 * 类描述：
 * 创建人：${徐家浩}
 * 创建时间：2017/2/17 20:01
 * 修改人：${徐家浩}
 * 修改备注：
 */
public abstract class VolleyInterface {
    private Context mContext;
    public static Response.Listener<String> mListener;
    public static Response.ErrorListener mErrorListener;

    public VolleyInterface(Context context, Response.Listener<String> listener, Response.ErrorListener errorListener) {
        this.mContext = context;
        this.mListener = listener;
        this.mErrorListener = errorListener;
    }



    public abstract void onMySuccess(String result);

    public abstract void onMyError(VolleyError error);

    //Success
    public Response.Listener<String> loadingListener() {
        mListener = new Response.Listener<String>() {
            @Override
            public void onResponse(String response) {
                onMySuccess(response);
            }
        };
        return mListener;
    }

    //Error
    public Response.ErrorListener errorListener() {
        mErrorListener = new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                onMyError(error);
            }
        };
        return mErrorListener;

    }

}
